<%--
  Created by IntelliJ IDEA.
  User: 18318
  Date: 2022/7/7
  Time: 11:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%--fpa报表统计--%>
<html>
<head>

  <title>mht报表统计</title>
  <script src="${pageContext.request.contextPath}/static/echarts/echarts.js"></script>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css" media="all">
  <script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
  <script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
</head>
<body>
<!-- 为 ECharts 准备一个定义了宽高的 DOM，必须定                   义宽高才可以显示 -->
<div style="width: 100%;height: 100%;" id="shopping"></div>
</body>
<script type="text/javascript">
      $.ajax({
        url: "${pageContext.request.contextPath}/view/queryResultToReport.do",
        dataType: "json",
        type: "post",
        success: function (re) {
          var shopping = echarts.init(document.getElementById('shopping'), 'dark');

          // 指定图表的配置项和数据
          var optionShopping = {

            title: {
              text: 'Fpa性格测试',
              subtext: '测试人数：' + (Number(re.data.r) + Number(re.data.y) + Number(re.data.b) + Number(re.data.g) + Number(re.data.f)),
              left: 'left'
            },
            tooltip: {},
            legend: {
              left: 'center',
              data: ['人数']
            },
            xAxis: {
              type: 'category',
              data: ['红色性格', '黄色性格', '蓝色性格', '绿色性格', '复合性格']
            },
            yAxis: {
              type: 'value',
              gridIndex: 0
            },
            grid: {top: '50%'},

            series: [
              //折线图
              {
                name: '人数',
                data: [re.data.r, re.data.y, re.data.b, re.data.g, re.data.f],
                type: 'line',
                symbolSize: 10,
                lineStyle: {
                  color: '#39c5bb',
                  width: 2,
                },
                itemStyle: {
                  color: '#66ccff'
                },
                smooth: true
              },
              //饼图
              {
                name: 'Access From',
                type: 'pie',
                radius: '25%',
                center: ['50%', '20%'],
                data: [
                  {value: re.data.r, name: '红色性格'},
                  {value: re.data.y, name: '黄色性格'},
                  {value: re.data.b, name: '蓝色性格'},
               {value: re.data.f, name: '复合性格'},
                ],
                itemStyle: {
                  normal: {//柱子颜色
                    color: function (colors) {
                      var colorList = [
                        '#dc4242',
                        '#e3e84c',
                        '#4c67d2',
                        '#69d54e',
                        '#945FCF'];
                      return colorList[colors.dataIndex];
                    }

                  }
                },
                emphasis: {
                  itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                  }
                }
              }

            ]
          };

          // 使用刚指定的配置项和数据显示图表。
          shopping.setOption(optionShopping);
        }
      })



</script>
</html>